package com.hopechart.micro;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.hopechart.micro.runner.StartRunner;
import com.hopechart.micro.util.JsonUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 		<br/> 应用程序入口
 * </p>
 * 
 * @author daijiang@hopechart.com
 * @date 2017-10-30 09:48:43
 * @copyright 杭州鸿泉数字设备有限公司
 * @version V1.0.0
 */
@SpringBootApplication
public class MicroApplication {

	@Bean
	public StartRunner startRunner() {
		return new StartRunner();
	}

	@Bean
	public HttpMessageConverters fastJsonHttpMessageConverters() {
		FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
		List<MediaType> mediaTypeList = new ArrayList<MediaType>();
		mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
		fastConverter.setSupportedMediaTypes(mediaTypeList);
		fastConverter.setFeatures(JsonUtil.features);
		HttpMessageConverter<?> converter = fastConverter;
		return new HttpMessageConverters(converter);
	}

	public static void main(String[] args) {
		SpringApplication.run(MicroApplication.class, args);
	}
}
